package com.market.controller;

import cn.dev33.satoken.annotation.SaCheckLogin;
import com.market.service.VoucherOrderService;
import com.market.model.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 优惠券订单控制器
 * 处理优惠券订单相关的功能，包括秒杀优惠券
 * 所有接口需要用户登录才能访问
 */
@RestController
@RequestMapping("/voucher/order")
@SaCheckLogin
public class VoucherOrderController {
  @Autowired
  private VoucherOrderService voucherOrderService;
  
  /**
   * 秒杀优惠券
   * 用户抢购指定ID的优惠券
   * @param voucherId 优惠券ID
   * @return 操作结果
   */
  @PostMapping("/seckill/{id}")
  public R seckill(@PathVariable("id") String voucherId) {
    voucherOrderService.seckill(voucherId);
    return R.ok();
  }
}
